package net.alegen.android.pizzashop.ui;

import net.alegen.android.pizzashop.R;
import net.alegen.android.pizzashop.ui.order.OrderActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

/*
 * The class for the main activity, which appears when the user starts the application
 */
public class MainActivity extends Activity {

	private Button btnOrder; // Reference to the btnOrder from main_activity.xml layout
	private Button btnContact; // Reference to the btnContact from main_activity.xml layout
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	
    	// Default initialization
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
        
        // Get reference to btnOrderPizza object
        this.btnOrder = (Button)this.findViewById(R.id.btnOrder);
        // Get reference to btnContact object
        this.btnContact = (Button)this.findViewById(R.id.btnContact);
        
        // Set the onClick listeners
        this.setOnClickListeners();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main_activity, menu);
        return true;
    }
    
    /*
     * This method sets the OnClickListeners for the two buttons.
     */
    private void setOnClickListeners() {
    	
    	this.btnOrder.setOnClickListener(new View.OnClickListener() {			
			public void onClick(View v) {
				// Create intent
				Intent intent = new Intent(MainActivity.this, OrderActivity.class);
				// Start the activity
				MainActivity.this.startActivity(intent);
			}
		});
    	
    	this.btnContact.setOnClickListener(new View.OnClickListener() {			
			public void onClick(View v) {
				// Create intent
				Intent intent = new Intent(MainActivity.this, ContactActivity.class);
				// Start the activity
				MainActivity.this.startActivity(intent);
			}
		});
    }
}